import type { Receiving } from '@/interface';
import { request } from '../request';

/**
 * 新建
 * @param data
 */
export function createReceiving(data: Receiving) {
  return request.post<void>('/admin/receiving/create', data, {
    useErrMsg: true
  });
}

/**
 * 更新
 * @param data
 */
export function updateReceiving(data: Receiving) {
  return request.post<void>('/admin/receiving/update', data, {
    useErrMsg: true
  });
}

/**
 * 分页
 * @param data
 */
export function pageReceiving(data: Common.Page<Receiving>) {
  return request.post<Common.Page<Receiving>>('/admin/receiving/page', data, {
    useErrMsg: true
  });
}

/**
 * 新建
 * @param id
 */
export function delReceiving(id: string) {
  return request.delete<void>(`/admin/receiving/delete?id=${id}`, null, {
    useErrMsg: true
  });
}

/**
 * 获取收礼总金额
 * @param bookId
 */
export function getReceiveAmount(bookId: string) {
  return request.get<number>(`/admin/receiving/receiveAmount?bookId=${bookId}`, null, {
    useErrMsg: true
  });
}
